1. Field of the Invention
The present invention relates to computer memory. More specifically, the present invention relates to a method and an apparatus for managing compiled methods in a unified heap.
2. Related Art
Platform-independent computing systems typically provide dynamic allocation of storage space for objects such as classes, program methods, and compiled program methods plus storage space for the objects allocated by an executing program. An example of a platform-independent computing system is the Java Virtual Machine (JVM). The terms JAVA, JVM, and JAVA VIRTUAL MACHINE are trademarks of SUN Microsystems, Inc. of Santa Clara, Calif.
Some platform-independent virtual machines use several “heaps” for storing different types of objects. For example, one heap may be used for storing compiled methods, and another heap may be used for storing other types of objects. These separate heaps may cause under-utilization of the heap memory—one heap may be full while another heap is still empty. However, because of the division of the heap by storage type, a second heap cannot be used to store items destined for the first heap.
In order to maximize space efficiency, many platform-independent virtual machines use a unified heap, which stores all objects allocated by the platform-independent virtual machine. A problem with unified heaps arises while managing dynamically compiled program methods, which are created on demand and need to be evicted when they are no longer used. If compiled methods are inter-mixed with other objects, the only way to reclaim space used by a compiled method after it is no longer being used is to perform a full garbage collection on the entire heap. This garbage collection operation is time-consuming and can cause an undesirable interruption in the execution of a platform-independent program.
Hence, what is needed is a method and an apparatus which manages compiled methods in a unified heap without the problems cited above.